package com.alibaba.middleware.hsf.configserver.publisher;

import com.taobao.config.client.Publisher;
import com.taobao.config.client.PublisherRegistrar;
import com.taobao.config.client.PublisherRegistration;

import java.util.Scanner;

/**
 * Created by weipeng2k on 16/4/1.
 */
public class PublisherMain {
    public static void main(String[] args) {
        // 注册登记表
        // 发布者名称与DataId，其中DataId是标识与订阅方之间关系的Key，这个是关键
        PublisherRegistration<String> registration = new PublisherRegistration<String>("weipeng2k-publisher",
                "com.alibaba.OrderService:1.0.0");
        registration.setGroup("HSF");

        // 创建一个发布者
        Publisher<String> register = PublisherRegistrar.register(registration);
        Scanner scanner = new Scanner(System.in);

        String line;

        while ((line = scanner.nextLine()) != null) {
            if (line.equals("quit")) {
                break;
            } else {
                // 发布数据
                System.out.println("Publish:" + line);
                register.publish(line);
            }
        }
        System.exit(1);
    }
}
